package edu.ncsu.csc.ip.client;

import edu.ncsu.csc.ip.common.serializer.Transfer;

/**
 * A bean that has information about a specific RFC:
 * Its title, number, ttl, and who owns it.
 * 
 * 
 * 
 * @author Moin Ayazifar <mayazif@ncsu.edu>
 * @author Steven Elliott <sdelliot@ncsu.edu>
 * 
 */

public class RFCBean {

	@Transfer
	private Integer rfcNumber;
	
	@Transfer
	private String rfcTitle;
	
	@Transfer
	private Integer ttl;
	
	@Transfer
	private String hostname;
	
	@Transfer
	private String address;
	
	@Transfer
	private Integer port;

	/**
	 * @return the rfcNumber
	 */
	public Integer getRfcNumber() {
		return rfcNumber;
	}

	/**
	 * @param rfcNumber
	 *            the rfcNumber to set
	 */
	public void setRfcNumber(Integer rfcNumber) {
		this.rfcNumber = rfcNumber;
	}

	/**
	 * @return the rfcTitle
	 */
	public String getRfcTitle() {
		return rfcTitle;
	}

	/**
	 * @param rfcTitle
	 *            the rfcTitle to set
	 */
	public void setRfcTitle(String rfcTitle) {
		this.rfcTitle = rfcTitle;
	}

	/**
	 * @return the ttl
	 */
	public Integer getTtl() {
		return ttl;
	}

	/**
	 * @param ttl
	 *            the ttl to set
	 */
	public void setTtl(Integer ttl) {
		this.ttl = ttl;
	}

	public String getHostname() {
		return hostname;
	}

	public void setHostname(String hostname) {
		this.hostname = hostname;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public Integer getPort() {
		return port;
	}

	public void setPort(Integer port) {
		this.port = port;
	}

	@Override
	public boolean equals(Object rfcBean) {
		if(rfcBean==null)
			return false;
		if (rfcBean instanceof RFCBean
				&& ((RFCBean) rfcBean).getRfcNumber().intValue() ==getRfcNumber().intValue()
				&& ((RFCBean) rfcBean).getAddress().equals(
						getAddress())		
//				&& ((RFCBean) rfcBean).getHostname().equalsIgnoreCase(
//						getHostname())
				&& ((RFCBean) rfcBean).getPort().intValue() == getPort().intValue())
			return true;
		return false;

	}
	
	
	@Override
    public int hashCode() {
        int hash = 1;
        hash = hash * 17 + getRfcNumber();
        hash = hash * 31 + getPort().hashCode();
        hash = hash * 13 + (getAddress() == null ? 0 : getAddress().hashCode());
        return hash;
    }
}
